/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import { Form, Input, DatePicker, Select, InputNumber,  Button } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
import request from '@/utils/request';
import 'braft-editor/dist/index.css'
import BraftEditor from 'braft-editor'
import config from '@/config/config'
import {download,getFileType} from '@/utils/utils';
const FormItem = Form.Item;
const Option = Select.Option;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      all_roles:[],
      html:'', // 设置编辑器初始内容
    };
  }
  componentDidMount() {
    const mailHistory=this.props.mailHistory
    if(mailHistory){
      this.setState({
        html:mailHistory
      })
    }
  }
  render() {



    return (
      <div>
        <div style={{padding:'10px 15px',background:'rgb(242, 242, 242)',fontSize:'16px'}}>
          <h4 style={{marginBottom:'3px',color:'#555'}}>发件人 : {this.props.editRecord.operator_name}</h4>
          <h4 style={{marginBottom:'0',color:'#555'}}>时&nbsp;&nbsp;&nbsp; 间 : {this.props.editRecord.created_at}</h4>
          {this.props.editRecord.attachments&&this.props.editRecord.attachments.length>0&&<h4 style={{marginBottom:'0',color:'#555'}}>附&nbsp;&nbsp;&nbsp; 件 :
            {
              this.props.editRecord.attachments.map((item,index)=>{
                return <span  key={index} onClick={()=>{
                  download(`${config.prefix}/attachments/${item.key}/download??token=Bearer ${sessionStorage.getItem('token')}`)
                }} title={'点击下载'} style={{marginRight:'10px',cursor:'pointer',color:'#1278f3',textDecoration:'underline'}} > {item.name}</span>
              })
            }
         </h4>
          }
        </div>

        <div className="detailImgWrap"  style={{padding:'10px',fontSize:'16px'}} dangerouslySetInnerHTML={{ __html:this.props.editRecord.content}}></div>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
